package com.lipuwater.agent.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池管理类
 */
public class ThreadUtils {
	private static ThreadUtils instance;
	/**
	 * 可缓存线程池，如果线程池长度超过处理需要，可灵活回收空闲线程
	 */
	private ExecutorService executorService;

	public static ThreadUtils getInstance() {
		if (null == instance) {
			instance = new ThreadUtils();
		}
		return instance;
	}

	public ExecutorService getExecutorService() {
		if (executorService == null) {
			executorService = Executors.newCachedThreadPool();
		}
		return executorService;
	}

	public void unExecutorService() {
		executorService.shutdown();
		executorService = null;
	}

}
